package com.ruoyi.configManage.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.configManage.domain.Logistics;
import com.ruoyi.configManage.service.ILogisticsService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物流公司Controller
 * 
 * @author ruoyi
 * @date 2025-09-23
 */
@RestController
@RequestMapping("/logisticsConfig/logisticsConfig")
public class LogisticsController extends BaseController
{
    @Autowired
    private ILogisticsService logisticsService;

    /**
     * 查询物流公司列表
     */
    //@PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(Logistics logistics)
    {
        startPage();
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        return getDataTable(list);
    }

    /**
     * 导出物流公司列表
     */
   // @PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:export')")
    @Log(title = "物流公司", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Logistics logistics)
    {
        List<Logistics> list = logisticsService.selectLogisticsList(logistics);
        ExcelUtil<Logistics> util = new ExcelUtil<Logistics>(Logistics.class);
        util.exportExcel(response, list, "物流公司数据");
    }

    /**
     * 获取物流公司详细信息
     */
   // @PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(logisticsService.selectLogisticsById(id));
    }

    /**
     * 新增物流公司
     */
   // @PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:add')")
    @Log(title = "物流公司", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.insertLogistics(logistics));
    }

    /**
     * 修改物流公司
     */
  //  @PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:edit')")
    @Log(title = "物流公司", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Logistics logistics)
    {
        return toAjax(logisticsService.updateLogistics(logistics));
    }

    /**
     * 删除物流公司
     */
   // @PreAuthorize("@ss.hasPermi('logisticsConfig:logisticsConfig:remove')")
    @Log(title = "物流公司", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(logisticsService.deleteLogisticsByIds(ids));
    }
}
